Skip to content

fix(expect): resolve message on assertion errors#10989

Merged
SimenB merged 1 commit intojestjs:masterfrom
SimenB:resolve-jest-assertion-message
Dec 30, 2020
Merged

fix(expect): resolve message on assertion errors#10989
SimenB merged 1 commit intojestjs:masterfrom
SimenB:resolve-jest-assertion-message

Conversation

@SimenB
Copy link
Copy Markdown
Member

@SimenB SimenB commented Dec 30, 2020

Summary

When the error is thrown from expect, there's not reason to keep the message property a function. A function is removed by JSON.stringify, so it's lost when transferred between workers. And the structured clone used by worker_threads throws as the message function references out of scope variables.

Extracted from #10981.

Test plan

Test tweaked

// reporter could access the actual and expected objects of the result
// for example in order to display a custom visual diff
error.matcherResult = result;
error.matcherResult = {...result, message};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message is resolved to a string on line 275

@SimenB SimenB merged commit c2f152d into jestjs:master Dec 30, 2020
@SimenB SimenB deleted the resolve-jest-assertion-message branch December 30, 2020 16:12
@github-actions
Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants